package com.example.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;

import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path="/app/main/MainActivity")
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    private TextView note;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ARouter.openLog();
        ARouter.openDebug();
        ARouter.init(getApplication());

        Button btn_Activity = (Button) findViewById(R.id.btn_Activity);
        Button btn_Anonymous = (Button) findViewById(R.id.btn_Anonymous);
        Button btn_Bind = (Button) findViewById(R.id.btn_Bind);
        Button btn_Inside = (Button) findViewById(R.id.btn_Inside);
        Button btn_Outside = (Button) findViewById(R.id.btn_Outside);
        Button btn_ButterKnife = (Button) findViewById(R.id.btn_ButterKnife);
        Button btn_Configuration = (Button) findViewById(R.id.btn_Configuration);
        Button btn_Progress = (Button) findViewById(R.id.btn_Progress);

        note = (TextView) findViewById(R.id.note);

        ButterKnife.bind(this);

        btn_Activity.setOnClickListener(this);  //Activity绑定
        btn_Anonymous.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                note.setText("点击了按钮:匿名内部类");
            }
        }); //匿名内部类
        btn_Inside.setOnClickListener(new InsideListener()); //内部类
        btn_Outside.setOnClickListener(new OutsideListener(note));//外部类
    }

    @OnClick(R.id.btn_ButterKnife)
    public void OnClick(){
        note.setText("点击了按钮:ButterKnife绑定");
    }
    @OnClick(R.id.btn_Configuration)
    public void OnClickConfiguration(){
        ARouter.getInstance().build("/app/main/ConfigurationTest").navigation();
    }
    @OnClick(R.id.btn_Progress)
    public void OnClickButter(){
        ARouter.getInstance().build("/app/main/ProgressDialogTest").navigation();
    }


    public void onClick(View v){
        note.setText("点击了按钮:采用Activity作为监听器");
    }
    public void OnClickBind(View v){   //绑定到标签
        note.setText("点击了按钮:绑定到标签");
    }
    class InsideListener implements View.OnClickListener{
        @Override
        public void onClick(View v){
            note.setText("点击了按钮:内部类");
        }
    }

}
